package cn.iocoder.yudao.module.member.dal.mysql.userpointrecords;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.userpointrecords.UserPointRecordsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.userpointrecords.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 用户积分流水 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserPointRecordsMapper extends BaseMapperX<UserPointRecordsDO> {

    default PageResult<UserPointRecordsDO> selectPage(UserPointRecordsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserPointRecordsDO>()
                .betweenIfPresent(UserPointRecordsDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UserPointRecordsDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserPointRecordsDO::getOpType, reqVO.getOpType())
                .eqIfPresent(UserPointRecordsDO::getBizType, reqVO.getBizType())
                .eqIfPresent(UserPointRecordsDO::getBizId, reqVO.getBizId())
                .eqIfPresent(UserPointRecordsDO::getPoints, reqVO.getPoints())
                .eqIfPresent(UserPointRecordsDO::getRemark, reqVO.getRemark())
                .orderByDesc(UserPointRecordsDO::getId));
    }

    Integer useTotalPoints(@Param("userId") Long userId);

}